<template>
	<div class="portal_user_info">
		<a-space align="center" direction="vertical" :size="16">
			<a-avatar :size="96" :image-url="userAvatar" />
			<h4>{{ userInfo.nickname }}</h4>
			<p>{{ userRoles }}</p>
			<a-button type="outline" shape="round" @click="handlePersonalSetting">
				<template #icon>
					<icon-settings />
				</template>
				个人设置
			</a-button>
		</a-space>
		<div class="btn">
			<a-link href="/link"><icon-user #icon /></a-link>
			<a-link href="link"><icon-idcard #icon /></a-link>
			<a-link href="link"><icon-star #icon /></a-link>
		</div>
	</div>
</template>

<script lang="ts" setup>
import { useUserStore } from '@/stores';
const emit = defineEmits(['setting']);
const userInfo = useUserStore().userInfo;
const userAvatar = computed(() => {
	return userInfo.avatar.replace(/192.168.1.109/g, '10.20.30.2');
});
const userRoles = computed(() => {
	return userInfo.roleNames.join('|');
});
const handlePersonalSetting = () => {
	emit('setting', true);
};
</script>

<style lang="scss" scoped>
.portal_user_info {
	display: flex;
	flex-direction: column;
	margin-top: 16px;
	height: 320px;
	.arco-space {
		flex: 1;
		overflow: hidden;
	}
	h4 {
		color: #fff;
		font-size: 18px;
		text-align: center;
	}
	p {
		color: #fff;
		text-align: center;
	}
	.btn {
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-shrink: 0;
		padding: 16px;
	}
	.arco-link {
		color: #fff;
		padding: 4px;
		font-size: 24px;
		&:hover {
			color: rgb(var(--link-6));
		}
	}
}
</style>
